package com.baseframe.user.entity.vo;

import com.baseframe.tool.utils.data.BeanUtil;
import com.baseframe.user.entity.BaseUser;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = true)
public class BaseUserVO extends BaseUser {

    /**
     * 状态名称
     */
    private String statusName;

    /**
     * 角色名称
     */
    private String roleName;

    /**
     * 性别名称
     */
    private String genderName;

    /**
     * 是否关注
     */
    private boolean follow;

    /**
     * 调连电话
     */
    private String fullPhone;



    public static List<BaseUserVO> build(List<BaseUser> baseUserList){
        List<BaseUserVO> baseUserVOList = new ArrayList<>();

        for (BaseUser baseUser : baseUserList) {

            BaseUserVO baseUserVO = new BaseUserVO();

            BeanUtils.copyProperties(baseUser,baseUserVO);

            baseUserVO.setStatusName(baseUser.getStatus()==0?"正常":"已封禁");
            baseUserVO.setPassword(null);
            baseUserVO.setGenderName(baseUser.getGender()==0?"女":"男");
        }

        return baseUserVOList;
    }

}
